package com.hzeport.bgs22emduty.inbound.api;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hzeport.bgs22emduty.config.login.LoginCompoentService;
import com.hzeport.bgs22emduty.config.login.UserInfoDetailVO;
import com.hzeport.bgs22emduty.config.systemLog.OperLog;
import com.hzeport.bgs22emduty.dto.subsidy.ParamSubSidyDetailDTO;
import com.hzeport.bgs22emduty.dto.subsidy.ParamSubsidyRemoveDTO;
import com.hzeport.bgs22emduty.dto.subsidy.ParamSubsidySaveDTO;
import com.hzeport.bgs22emduty.entity.ParamSubsidy;
import com.hzeport.bgs22emduty.service.ParamSubsidyService;
import com.hzeport.bgs22emduty.vo.base.PageVO;
import com.hzeport.bgs22emduty.common.base.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 参数表-值班配置表：
此表中存储，各部门值班的参数配置
 *
 * @author code generator
 * @date 2022-12-02 11:21:59
 */
@RestController
@AllArgsConstructor
@RequestMapping("/paramsubsidy")
@Api(value = "paramsubsidy", tags = "补贴参数配置表")
@Slf4j
public class ParamSubsidyController {

    @Resource
    private  ParamSubsidyService paramSubsidyService;
    @Resource
    private LoginCompoentService loginCompoentService;

    @ApiOperation(value = "列表")
    @RequestMapping(value = "list",method = RequestMethod.POST)
    public  BaseResult<Page<ParamSubsidy>> list(@RequestBody  PageVO pageVO) {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return  paramSubsidyService.list(pageVO,userInfoDetailVO);
    }

    @ApiOperation(value = "删除")
    @RequestMapping(value = "delete",method = RequestMethod.POST)
    @OperLog( systemName = "BTCS", description = "BTSC")
    public BaseResult removeById(@RequestBody ParamSubsidyRemoveDTO id) {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return paramSubsidyService.delete(id.getId(),userInfoDetailVO);
    }

    @ApiOperation(value = "获取详情")
    @RequestMapping(value = "detail",method = RequestMethod.GET)
    public BaseResult<ParamSubSidyDetailDTO> detail(@RequestParam("id") String id) throws Exception {
        return paramSubsidyService.detail(id);
    }

    @ApiOperation(value = "保存")
    @OperLog( systemName = "BTCS", description = "BTBC")
    @RequestMapping(value = "save",method = RequestMethod.POST)
    public BaseResult save(@RequestBody ParamSubsidySaveDTO paramSubsidySaveVO) throws Exception {
        UserInfoDetailVO userInfoDetailVO=loginCompoentService.getUserInfo();
        return  paramSubsidyService.saveData(paramSubsidySaveVO,userInfoDetailVO);
    }

//    @ApiOperation(value = "根据关区id获取所有时段")
//    @RequestMapping(value = "listTime",method = RequestMethod.POST)
//    public BaseResult<List<ParamSubsidy>> listTime(@RequestParam("id") String id)  {
//        return  paramSubsidyService.listTime(id);
//    }
}
